package com.x.windows;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;

import java.util.HashMap;
import java.util.Map;

public class WebRTCVerticle extends AbstractVerticle {

  Map<String,String> m1 = new HashMap<>();
  @Override
  public void start(Promise<Void> startPromise) throws Exception {
    vertx.createHttpServer().requestHandler(httpServerRequest->{
      vertx.eventBus().consumer(m1.get(httpServerRequest.getParam("self")),(msg)->{
        vertx.eventBus().publish(m1.get(httpServerRequest.getParam("dm")),msg.body());
      });
    }).webSocketHandler(serverWebSocket->{
      m1.put(serverWebSocket.path().substring(1),serverWebSocket.textHandlerID());

    }).listen(1223);
  }
}
